unit uRepSendCountBillNo;

interface

uses
  WinApi.Windows, WinApi.Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniButton, uniBitBtn, uniPanel,
  uniBasicGrid, uniDBGrid, Data.DB, Datasnap.DBClient, ClientRowSet;

type
  TFrmRepSendCountBillNo = class(TUniForm)
    UniPanel1: TUniPanel;
    btClose: TUniBitBtn;
    GridBill: TUniDBGrid;
    crsBill: TClientRowSet;
    dsBill: TDataSource;
    crsBillBILL_NO: TStringField;
    crsBillCARGO_CNT: TIntegerField;
    procedure btCloseClick(Sender: TObject);
    procedure UniFormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure ShowBillList(sendNode, destNode, batchNo, opTime: string);
  end;

function FrmRepSendCountBillNo: TFrmRepSendCountBillNo;

implementation

{$R *.dfm}

uses
  MainModule, uniGUIApplication, ExpModule, uCommFunction;

function FrmRepSendCountBillNo: TFrmRepSendCountBillNo;
begin
  Result := TFrmRepSendCountBillNo(UniMainModule.GetFormInstance(TFrmRepSendCountBillNo));
end;

procedure TFrmRepSendCountBillNo.btCloseClick(Sender: TObject);
begin
  Self.Close;
end;

procedure TFrmRepSendCountBillNo.ShowBillList(sendNode, destNode, batchNo, opTime: string);
var
  SQLText: string;
begin
  SQLText := 'SELECT m.bill_no,i.cargo_cnt FROM tsp_order m JOIN tsp_trance i ON i.bill_no=m.bill_no ' +
    ' WHERE m.group_code=' + QuotedStr(dmExpress.UserInfo.GroupCode) + ' AND i.group_code=' + QuotedStr(dmExpress.UserInfo.GroupCode) +
    //' AND m.tsp_state=10 AND i.op_code=''10''' +
    ' AND i.op_code=''10''' +
    ' AND i.op_time>=' + QuotedStr(opTime) + ' AND i.op_time<=' + QuotedStr(opTime + ' 23:59:59');
  if sendNode <> '' then
    SQLText := SQLText + ' AND i.node_no=' + QuotedStr(sendNode);
  if destNode <> '' then
    SQLText := SQLText + ' AND i.next_node=' + QuotedStr(destNode);
  if batchNo <> '' then
    SQLText := SQLText + ' AND i.batch_no=' + QuotedStr(batchNo);
  crsBill.Close;
  crsBill.CommandText := SQLText;
  crsBill.IndexFieldNames := 'bill_no';
  crsBill.Open;
end;

procedure TFrmRepSendCountBillNo.UniFormCreate(Sender: TObject);
begin
  SetCompoentLanguage(Self);
end;

end.
